import { App, EventType } from "@glowjs/core";

export let glowApp: { value: App } = { value: null! };

/**
 * 创建一个3D应用
 */
export async function createGlowApp(): Promise<void> {
    //执行一些前置初始化操作

    //手动创建一个容器
    let container: HTMLDivElement = document.createElement('div');
    container.style.width = "100%";
    container.style.height = "100%";
    container.style.position = 'absolute';

    let app: App = glowApp.value = new App({
        container,
        projectFile: 'glowjs/project/file/project.json',
        licenseFile: 'glowjs/project/license/license.txt'
    });

    //执行一些后置初始化操作

    app.once(EventType.LevelCreate, () => { 
        //执行一些初始化操作
        console.log('LevelCreate');
    });
    app.once(EventType.AfterLevelLoad, () => {
        console.log('AfterLevelLoad');
     });
}